package com.cjy.demo3;

import org.apache.shiro.crypto.SecureRandomNumberGenerator;
import org.apache.shiro.crypto.hash.SimpleHash;

/**
 * @author Cheng JiYe
 * @description:
 * @date 2021/4/3 19:44
 */
public class Md5Salt {
  public static void main(String[] args) {
    String password = "123456";
    String salt = new SecureRandomNumberGenerator().nextBytes().toString();
    // 加密次数：2
    int times = 2;
    // 加密算法
    String alogrithmName = "md5";
    String encodePassword = new SimpleHash(alogrithmName, password, salt, times).toString();
    String msg = "原始密码是 %s , 盐是： %s, 运算次数是： %d, 运算出来的密文是：%s ";
    System.out.printf(msg, password, salt, times, encodePassword);
  }
}
